package com.qf.student.controller;


import com.qf.student.entity.Student;
import com.qf.student.response.R;
import com.qf.student.service.IStudentService;
import com.qf.student.utils.TokenUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2022-11-21
 */
@Slf4j
@RestController
@RequestMapping("/student")
@Api(value = "学生控制层")
public class StudentController {

    @Autowired
    private IStudentService studentService;

    @RequestMapping("/getInfo")
    @ApiOperation(value = "查询所有学生的方法")
    public R getUpdateInfo(HttpServletRequest request) {
        Integer userId = TokenUtils.getUserId(request);
        return studentService.getUpdateInfo(userId);
    }

    @RequestMapping("/updateInfo")
    public R updateInfo(HttpServletRequest request, Student student) {
        Integer userId = TokenUtils.getUserId(request);
        return studentService.updateInfo(userId, student);
    }

}
